const virtualPath = process.env.virtualPath || '';
const fs = require('fs');
const path = require('path');
const ms = require('ms');

module.exports = appInfo => {
    const config = {

        //http自动转Https中间件默认关闭
        toHttps: {
            enable: false
        },

        ipWhiteList: ['127.0.0.1'],

        // 数据库配置
        mysql: {
            client: {
                // host
                host: '127.0.0.1',
                // port
                port: '3306',
                // username
                user: 'root',
                // password
                password: '12345678',
                // database
                database: 'sys',
                connectionLimit: 50,
            },
            app: true,
        },

        sequelize: {
            dialect: 'mysql',
            dialectOptions: {
                charset: 'utf8mb4',
            },
            host: '127.0.0.1',
            port: 3306,
            database: 'sys',
            username: 'root',
            password: '12345678',
            timezone: '+08:00', // 保存为本地时区
            dialectOptions: {
                dateStrings: true,
                typeCast(field, next) {
                    // for reading from database
                    if (field.type === "DATETIME") {
                        return field.string();
                    }
                    return next();
                }
            }
        },

        // 验证码配置项
        monkeySMS: {
            enable: true,
            codeLength: 4, //验证码位数
            intervalTime: 1, //验证码发送间隔 => 单位：分钟
            validTime: 2, //验证码有效期 => 单位：分钟
        },

        security: {
            // 伪造请求
            csrf: {
                enable: false,
            },
        },

    };
    return config;
}